﻿#ifndef UDPMSG_H
#define UDPMSG_H

#include "qtypes.h"

#include <qbytearray.h>
class UdpMsg
{
public:
    UdpMsg();
    quint16 _tag;
    quint16 _ver;
    quint32 _inc;
    quint32 _cmd;
    quint32 _subCmd;
    QByteArray _data;
    QByteArray ToBA();
    bool FromBA(QByteArray ba);
    enum  CMD{
        CMD_RECORDER_SEND = 0x0506
    };
    enum SUBCMD{
        SUBCMD_SENDER = 0x0A,
        SUBCMD_RECEIVER = 0x0B
    };
protected:
    quint16 GetCrc16Value(QByteArray pu8Data);
    quint16 GetCrc16(QByteArray ba);
    bool GetSubCmdByMask(int mask);
private:
    static const quint16 u16CrcTable[16] ;
};

#endif // UDPMSG_H
